package com.stardust.controller;

import com.stardust.pojo.Questions;
import com.stardust.pojo.ResultControl;
import com.stardust.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Controller
@RequestMapping("Question")
public class QuestionController {

    @Autowired
    private QuestionService questionService;

    @RequestMapping("Exceptiontest")
    @ResponseBody
    public ResultControl Expectiontest(){
        int a = 0/1;
        System.out.println(a);
        return new ResultControl();
    }

    @RequestMapping(value = "",method = RequestMethod.GET)
    @ResponseBody
    public ResultControl add(@RequestBody Questions questions){
        questions.setCreateDate(new Date());
        return questionService.add(questions);
    }
}
